//
//  ZYCTeachingTeachLearningDetailContentCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/31.
//

#import "ZYCTeachingTeachLearningDetailContentCell.h"
#import "ZYCTeachLearningPaperModel.h"
#import "ZYCTeachLearningDetailModel.h"

#define maxContent 200

#define ZYCContentPlaceholder @"请输入不超过200字符数的回答~"
#define ZYCContentPlaceholderColor [UIColor colorWithHexString:@"#999999" alpha:1.0]

@interface ZYCTeachingTeachLearningDetailContentCell ()
@property (nonatomic, strong) UILabel *questionLabel;
@property (nonatomic, strong) UILabel *line;
@property (nonatomic, strong) UILabel *contentLabel;

@end
@implementation ZYCTeachingTeachLearningDetailContentCell

- (void)setModel:(ZYCDetailSubjectModel *)model{
    _model = model;
    _questionLabel.attributedText = [self returnFuwenBen:[NSString stringWithFormat:@"%@、 %@ %@",model.sortNum,model.subjectTypeStr,model.subjectTitle]];
    _contentLabel.text = model.answerContent;
}

- (NSMutableAttributedString *)returnFuwenBen:(NSString *)string{
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:string];
    NSRange rang0 = NSMakeRange(0, self.model.sortNum.length);
    [attriString addAttribute:NSFontAttributeName value:kCustomFont(@"PingFangSC-Medium", 16.0f) range:rang0];
    NSRange rang1 = NSMakeRange(self.model.sortNum.length + 1, self.model.subjectTypeStr.length + 1);
    [attriString addAttribute:NSForegroundColorAttributeName value:HEX_RGB(@"#39A85B") range:rang1];
    return attriString;;
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.questionLabel];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.contentLabel];
        [self.questionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self.contentView).offset(14.0f);
            make.right.equalTo(self.contentView).offset(-14.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(14.0f);
            make.right.equalTo(self.contentView).offset(-14.0f);
            make.top.equalTo(self.questionLabel.mas_bottom).offset(14.0f);
            make.height.mas_equalTo(0.5f);
        }];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.line.mas_bottom).offset(16.0f);
            make.left.equalTo(self.contentView).offset(14.0f);
            make.right.equalTo(self.contentView).offset(-14.0f);
            make.bottom.equalTo(self.contentView).offset(-14.0f).priorityHigh();
        }];

    }
    return self;
}


 


- (UILabel *) questionLabel{
    if (!_questionLabel) {
        _questionLabel = [[UILabel alloc] init];
        _questionLabel.textAlignment = NSTextAlignmentLeft;
        _questionLabel.font = kCustomFont(@"PingFangSC-Light", 16.0f);
        _questionLabel.numberOfLines = 0;
    }
    return _questionLabel;
}

- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EBEBEB");
    }
    return _line;
}


- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel  LabelWithFont:kCustomFont(@"PingFangSC-Light", 16.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}


@end
